package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.CheckItemService;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhangmeng
 * @description 检查项Controller
 * @date 2019/9/16
 **/
@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
public class MobileSetmealController {

    @Autowired
    private SetMealService setMealService;


    /**
     * 根据Id查询
     *
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Integer id) {
        log.info("套餐查询",id);
        System.out.println(id);
        Setmeal setmeal = setMealService.selectBySetMealId(id);
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }

    /**
     * 查询所有检查项
     * @return
     */
    @RequestMapping("/getSetmeal")
    public Result findAll(){
        log.info("[套餐查询-查询所有]~");
        List<Setmeal> setmeals = setMealService.findAll();
        return new Result(true,MessageConst.QUERY_CHECKITEM_SUCCESS,setmeals);
    }
}
